package me.tuyou.stream;

import org.apache.flink.api.java.tuple.Tuple1;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.ConnectedStreams;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class JoinTest {
    public static void main(String[] args) throws Exception {
        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<Tuple1<String>> source1 = env.fromElements(
                new Tuple1<>("Honda"),
                new Tuple1<>("CROWN"));
        DataStream<Tuple2<String, Integer>> source2 = env.fromElements(
                new Tuple2<>("BMW", 35),
                new Tuple2<>("Tesla", 40));

        ConnectedStreams<Tuple1<String>, Tuple2<String, Integer>> connect = source1.connect(source2);
        connect.getFirstInput().print("first");
        connect.getSecondInput().print("second");
        env.execute();
    }
}
